package P3.T04;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Cats implements Iterable<Cat> {
    private List<Cat> cats;

    public Cats(Cat[] cats) {
        this.cats = Arrays.stream(cats).toList();
    }
    public void add(Cat c){
        cats.add(c);
    }
    public Iterator<Cat> iterator(){
        return new CatIterator();
    }
    private class CatIterator implements Iterator<Cat>{
        private int pos=0;
        @Override
        public boolean hasNext() {
            return pos<cats.size();
        }

        @Override
        public Cat next() {
            Cat c=cats.get(pos);
            pos++;
            return c;
        }
    }
}
